<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>

<body>
    <div id="app">
        <input type="text" v-model="firstName">
        <div>{{newName}}</div>

        <input type="text" v-model="account">
    </div>
    <!-- 应用场景： 数据变化时执行异步或开销大的操作 -->
    <script type="text/javascript" src="js/vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                firstName: "huwei",
                account: ''
            },
            watch: {
                firstName: function (val) { // val 是最新值
                    console.log("val =" + val);
                    this.newName = "hello " + val
                },
                account: function (val) { 
                     //请求接口，验证账号合法性
                }
            },
        })
    </script>
</body>

</html>